package cn.stylefeng.guns.sys.modular.dbcontentapproval.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.dbcontentapproval.entity.DbContentapproval;
import cn.stylefeng.guns.sys.modular.dbcontentapproval.model.params.DbContentapprovalParam;
import cn.stylefeng.guns.sys.modular.dbcontentapproval.service.DbContentapprovalService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 内容审核列表控制器
 *
 * @author zhaoyiheng
 * @Date 2020-08-20 15:35:53
 */
@Controller
@RequestMapping("/dbContentapproval")
public class DbContentapprovalController extends BaseController {

    private String PREFIX = "/modular/dbContentapproval";
    private String PREFIX1 = "/modular/dbServicelist/dbServicelist";

    @Autowired
    private DbContentapprovalService dbContentapprovalService;

    /**
     * 跳转到主页面
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @RequestMapping("")
    public String index() {
        return PREFIX1 + "/dbContentapproval.html";
    }

    /**
     * 新增页面
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX1 + "/dbService_apply.html";
    }

    /**
     * 编辑页面
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX1 + "/dbService_apply.html";
    }

    /**
     * 新增接口
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(DbContentapprovalParam dbContentapprovalParam) {
        this.dbContentapprovalService.add(dbContentapprovalParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(DbContentapprovalParam dbContentapprovalParam) {
        this.dbContentapprovalService.update(dbContentapprovalParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(DbContentapprovalParam dbContentapprovalParam) {
        this.dbContentapprovalService.delete(dbContentapprovalParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(DbContentapprovalParam dbContentapprovalParam) {
        DbContentapproval detail = this.dbContentapprovalService.getById(dbContentapprovalParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(DbContentapprovalParam dbContentapprovalParam) {
        return this.dbContentapprovalService.findPageBySpec(dbContentapprovalParam);
    }

    /**
     * 批准按钮
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @ResponseBody
    @RequestMapping("/onApprove")
    public ResponseData onApprove(DbContentapprovalParam dbContentapprovalParam) {
        this.dbContentapprovalService.onApprove(dbContentapprovalParam);
        return ResponseData.success();
    }


    /**
     * 驳回按钮
     *
     * @author zhaoyiheng
     * @Date 2020-08-20
     */
    @ResponseBody
    @RequestMapping("/onDown")
    public ResponseData onDown(DbContentapprovalParam dbContentapprovalParam) {
        this.dbContentapprovalService.onDown(dbContentapprovalParam);
        return ResponseData.success();
    }

}


